package com.zqxq.lottery.service.esports.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zqxq.lottery.entity.o2o.esports.ESportsPlaywayO2O;
import com.zqxq.lottery.entity.po.esports.ESportsPlaywayPO;
import com.zqxq.lottery.entity.vo.esports.ESportsPlaywayVO;
import com.zqxq.lottery.entity.vo.order.UserOrderBetVO;
import com.zqxq.lottery.mapper.esports.ESportsPlaywayMapper;
import com.zqxq.lottery.service.esports.IESportsPlaywayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
@Slf4j
public class ESportsPlaywayServiceImpl extends ServiceImpl<ESportsPlaywayMapper, ESportsPlaywayPO> implements IESportsPlaywayService {

    @Override
    public List<ESportsPlaywayVO> getESportsPlayways(String matchId) {
        List<ESportsPlaywayVO> list = new ArrayList<>();
        return list;
    }

    @Override
    public ESportsPlaywayVO getESportsPlayway(String matchId,String playType) {
        ESportsPlaywayPO eSportsPlaywayPO = new ESportsPlaywayPO();
        eSportsPlaywayPO.setMatch_id(Long.valueOf(matchId));
        eSportsPlaywayPO.setPlay_id(Long.valueOf(playType));
        eSportsPlaywayPO = this.baseMapper.selectOne(eSportsPlaywayPO);
        ESportsPlaywayVO vo = ESportsPlaywayO2O.toVO(eSportsPlaywayPO);
        vo.setCloseTime(String.valueOf(eSportsPlaywayPO.getClose_time().getTime()));
        return vo;
    }

    @Override
    public UserOrderBetVO getMatchPlayTypeChoice(String userId, String period, String playType) {
        List<UserOrderBetVO> list = baseMapper.getMatchPlayTypeChoice(userId,period,playType);
        UserOrderBetVO userOrderBetVO  = null;
        if(list!=null && list.size()!=0){
            userOrderBetVO = list.get(0);
        }
        return userOrderBetVO;
    }

}
